package com.novunda.platform.entities;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.novunda.platform.entities.base.BaseEntity;
import com.novunda.platform.entities.base.DataEntity;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;

/**
 * 采集时间Entity
 *
 * @author Lizy
 * @version 2016-09-8
 */
@Entity
@Table(name = "conf_statistics_time")
@DynamicInsert
@DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class StatisticsTime extends DataEntity {
    /**
     * id
     */
    private Long id;

    /**
     * 周期区间名称
     */
    private String name;

    /**
     * 开始时间
     */
    private String beginTime;

    /**
     * 结束时间
     */
    private String endTime;
    /**
     * 统计采集
     */
    private Statistics statistics;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "name")
    @Length(min = 1, max = 20)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "begin_time")
    @Length(min = 1, max = 10)
    public String getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(String beginTime) {
        this.beginTime = beginTime;
    }

    @Column(name = "end_time")
    @Length(min = 1, max = 10)
    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    @ManyToOne
    @JoinColumn(name = "statistics_id", nullable = true)
    public Statistics getStatistics() {
        return statistics;
    }

    public void setStatistics(Statistics statistics) {
        this.statistics = statistics;
    }
}
